<script setup>
    import {useRouter} from 'vue-router'
    import {ref} from 'vue'

    let route = useRouter()
    let username = ref("")
    let password = ref("")

    function login(){
        if(username.value=="root"&&password.value=="123456"){
            window.sessionStorage.setItem("username",username.value)
            window.sessionStorage.setItem("password",password.value)
            route.push('/home')
        }else{
            alert("用户名或密码不正确")
        }

    }

</script>

<template>
  <div>
    <h1>Login页面</h1>

    用户名：<input type="text" v-model="username">
    密码：<input type="password" v-model="password">
    <button @click="login()">登录</button>
  </div>
</template>

<style scoped>

</style>
